/*****************************************************************************
 *
 *                      HUSONG PROPRIETARY INFORMATION
 *
 *          The information contained herein is proprietary to HUSONG
 *           and shall not be reproduced or disclosed in whole or in part
 *                    or used for any design or manufacture
 *              without direct written authorization from HUSONG.
 *
 *            Copyright (c) 2015 by HUSONG.  All rights reserved.
 *
 *****************************************************************************/
package me.send.data.service.mapper;

import java.util.List;
import java.util.Map;

import me.send.data.service.mapper.provider.ManagerProvider;
import me.send.data.service.pojo.Manager;
import me.send.data.service.pojo.ManagerPermission;
import me.send.data.service.pojo.ManagerPermissionTree;
import me.send.data.service.pojo.ManagerRole;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

/**
 * @author maxmin
 *
 * @date 2015年9月15日 上午9:36:40
 */
public interface ManagerMapper {
	
	/**
	 * 通过手机号获取管理员
	 * @param telephone
	 * @return
	 * @author maxmin
	 * @date 2015年9月15日上午9:40:40
	 */
	@Select(value = "SELECT manager_id managerId,password,nickname nickName,description,telephone,"
			+ "cityname cityName,status,headerpath,gender FROM manager WHERE  telephone=#{telephone}")
    public abstract Manager getByTelephone(String telephone);
	
	@Select(value="SELECT id,role_id roleid,manager_id managerId  FROM manager_role WHERE manager_id = #{managerId}")
	public abstract List<ManagerRole> getManagerRolesByUser(Manager manager);
	
	@SelectProvider(method = "getManagerPermissionByRoles", type = ManagerProvider.class)
	public abstract List<ManagerPermission> getManagerPermissionByRoles(Map<String,Object> params);
	
	@SelectProvider(method = "getManagerPermissionTreeByPermissions", type = ManagerProvider.class)
	public abstract List<ManagerPermissionTree> getManagerPermissionTreeByPermissions(Map<String,Object> params);
	
	@UpdateProvider(method = "insertManagerPermissionTree", type = ManagerProvider.class)
	public abstract void insertManagerPermissionTree(Map<String,Object> params);
	@Update("update manager set password=#{newpassword} where telephone=#{username} and password=#{oldpassword}")
	public abstract void update(Map<String,Object> param);

}
